# 修复video_processor.py文件中的语法错误
import fileinput
import sys

# 要修复的文件路径
file_path = r'd:\未知\yolo_apply\video_processing\video_processor.py'

# 读取文件内容
with open(file_path, 'r', encoding='utf-8') as f:
    lines = f.readlines()

# 替换有问题的代码行（第1849行附近）
for i in range(1845, 1855):  # 检查第1845-1854行
    if i < len(lines):
        if '# 错误率过高时触发警告和恢复' in lines[i]:
            # 替换接下来的几行代码
            if i+1 < len(lines):
                lines[i+1] = '                current_time = time.time()\n'
            if i+2 < len(lines):
                lines[i+2] = '                if error_count > 10 and (current_time - last_error_time > 30):\n'
            if i+6 < len(lines):
                lines[i+6] = '                    last_error_time = current_time\n'
            break

# 写回文件
with open(file_path, 'w', encoding='utf-8') as f:
    f.writelines(lines)

print(f"已成功修复 {file_path} 中的语法错误")